[experiment] first draft of init array syntax #143553
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch allows parsing of the syntax
init [ v1, v2, v3, .. ]
and certain level of type checking on HIR level.See Draft RFC, under tracking rust-lang/lang-team#336
Dragons ahead
This is a draft PR that is very experimental and it is posted only for very early feedback and it is not immediately mergeable.
init # ...
AST fragment as a start.The reason that this deviates from the original proposal, with the additional
#
, is to help with syntax ambiguity betweeninit[0]
as indexing into a valueinit
, versusinit [ 0 ]
as in-place initialisation.However, I would propose to switch to a macro based approach to the syntax to avoid such ambiguity.
Init
. It has the same generics structure as aClosure
and it is almost type-checked in the same way asClosure
, except that its return type expectation also contains the error type, which is to be unified with those from the nested in-place initialisation.This is still not functional, because for instance I still have to fill out some tables such as
late_bound_vars
.This patch does not include any THIR or MIR building.
The final state at which I would see this patch can be merged, is to at least we can type check the following smoke test.
Areas to improve
As of July 7th, I see that I need to work these out
InitTail
is not necessary, I should just drop itInitKind::Array
could be squashed so that it is just a list ofInitTail
nodesInitTail
sounds terrible and I regret the choice.r? @compiler-errors